package org.learn.test;
import java.util.Scanner;
public class ArrayAdd {
    public static void main(String[] args) {
        //数组扩容
        Scanner myScanner = new Scanner(System.in);
       int[] arr = {1,2,3};
       do {
           int[] arrNew = new int[arr.length + 1];
           for (int i = 0; i < arr.length; i++) {
               arrNew[i] = arr[i];
           }
           System.out.println("请输入你想要填加的值");
           int addNum = myScanner.nextInt();
           arrNew[arrNew.length - 1] = addNum;
           arr = arrNew;
           System.out.println("=== 数组扩容后===");
           for (int i = 0; i < arr.length; i++) {
               System.out.print(arr[i] + " ");
           }
           System.out.println("是否继续添加y/n");
           char key = myScanner.next().charAt(0);
           if( key == 'n'){
               break;
           }
       }while(true);{

        }
    }
}


